package com.hfxt.service.impl;
import com.hfxt.mapper.ClassifyMapper;
import com.hfxt.po.Classify;
import com.hfxt.service.ClassifyService;
import com.hfxt.dto.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@Service
public class ClassifyServiceImpl implements ClassifyService {

    @Autowired
    private ClassifyMapper classifyMapper;

    public Classify getClassifyById(Long id){
        return classifyMapper.getClassifyById(id);
    }

    public List<Classify>	getClassifyListByMap(Map<String,Object> param){
        return classifyMapper.getClassifyListByMap(param);
    }

    public Integer getClassifyCountByMap(Map<String,Object> param){
        return classifyMapper.getClassifyCountByMap(param);
    }

    public Integer qdtxAddClassify(Classify classify){
            classify.setCreatdTime(new Date());
            return classifyMapper.insertClassify(classify);
    }

    public Integer qdtxModifyClassify(Classify classify){
        classify.setUpdatedTime(new Date());
        return classifyMapper.updateClassify(classify);
    }

    public Integer qdtxDeleteClassifyById(Long id){
        return classifyMapper.deleteClassifyById(id);
    }

    public Integer qdtxBatchDeleteClassify(String ids){
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return classifyMapper.batchDeleteClassify(param);
    }

    public Page<Classify> queryClassifyPageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize){
        Integer total = classifyMapper.getClassifyCountByMap(param);
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<Classify> classifyList = classifyMapper.getClassifyListByMap(param);
        page.setList(classifyList);
        return page;
     }


}
